﻿using AutoMapper;
using B.S.BasicData.Api.Read.Application.Command.User;
using B.S.BasicData.Api.Read.DTO;
using B.S.BasicData.Domian.Entities.Account;
using B.S.BasicData.ErrorCode;
using B.S.BasicData.Infrastructure.Interface;
using MediatR;

namespace B.S.BasicData.Api.Read.Application.Handler.User
{
    public class GetListHandler : IRequestHandler<GetListCommand, ApiResult<List<ShengModel>>>
    {
        private readonly IBaseRepository<ShengModel> shengRepo;
        private readonly IMapper mapper;

        public GetListHandler(IBaseRepository<ShengModel> shengRepo, IMapper mapper)
        {
            this.shengRepo = shengRepo;
            this.mapper = mapper;
        }
        public Task<ApiResult<List<ShengModel>>> Handle(GetListCommand request, CancellationToken cancellationToken)
        {
            var res = new ApiResult<List<ShengModel>>();
            var sheng = shengRepo.GetAll();
            res.Message = "绑定成功";
            res.Code = ApiEnum.Ok;
            res.Data = sheng.ToList();
            return Task.FromResult(res);
        }


    }
}
